<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="manage/layout :: common_header(~{::title})">
    <title>网站留言管理-网站后台管理中心</title>
</head>
<body th:replace="manage/layout :: common_body(~{::div.layui-body})">
<div class="layui-body" style="padding:15px;">

    <div class="sp-wrapper">

        <fieldset class="layui-elem-field">
            <legend>按条件搜索</legend>
            <div class="layui-field-box">
                <form class="layui-form layui-form-pane1" method="get" th:action="@{/manage/message_list}">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <input type="text" name="title" th:value="${title}" placeholder="标题" class="layui-input">
                        </div>

                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-normal">搜索</button>
                            <i>总共：<span style="color: red" th:text="${totalSize}"></span>条记录</i>
                        </div>

                        <div class="layui-inline">

                        </div>
                    </div>

                </form>
            </div>
        </fieldset>


            <table class="layui-table dd-table" lay-even lay-skin="row">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>联系人</th>
                    <th>联系电话</th>
                    <th>email</th>
                    <th>留言内容</th>
                    <th>状态</th>
                    <th>回复内容</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item:${list}">
                    <td class="center" th:text="${item.id}"></td>
                    <td class="center" th:text="${item.linkMan}"></td>
                    <td th:text="${item.linkPhone}"></td>
                    <td class="center" th:text="${item.email}"></td>
                    <td class="center" th:text="${item.getContent()}"></td>

                    <td class="center" >
                        <span th:if="${item.getStatus()==0}">待回复</span>
                        <span th:if="${item.getStatus()==1}">已回复</span>
                    </td>
                    <td th:text="${item.replyRemark}"></td>
                    <td class="center">
                        <a class="layui-btn layui-btn-primary layui-btn-small reply" th:if="${item.status == 0}" th:attr="data-id=${item.id}" href="javascript:;"><i class="layui-icon-at"></i>登记回复</a>
                    </td>
                </tr>
                </tbody>
            </table>

        <div class="layui-box layui-laypage layui-laypage-default">

        </div>
        <div class="layui-box layui-laypage layui-laypage-default pageBox">
            <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
        </div>


        <script type="text/javascript">
            //JavaScript代码区域
            layui.use(['jquery','form','layer'], function () {
                var $$ = layui.jquery;
                var form = layui.form;
                var layer = layui.layer;
                $$(function(){


                    $$(".reply").click(function () {
                        var id = $$(this).attr('data-id');

                        layer.prompt({title: '填写联系客户的情况，并确认', formType: 2}, function(text, index){
                            var data={
                                id:id,
                                content:text
                            }

                            $$.ajax({
                                url: "/manage/message_reply",
                                type: "POST",
                                dataType: "JSON",
                                contentType: 'application/json',
                                data: JSON.stringify(data),
                                success: function (res) {
                                    if (res.code == 0) {
                                        layer.close(index);
                                        layer.msg('回复成功！您写下了：'+text);
                                        window.location.reload();
                                    } else {
                                        alert(res.msg);
                                    }
                                    // alert(JSON.stringify(res));
                                    return false;
                                }
                            });


                        });

                    })
                })
            });
        </script>


    </div>
</div>
</body>
<html>
